<template>
	<view class="page-fade-in" :style="{opacity: pageOpc}">
		<template v-if="pageOpc">
			<view class="content">
				<view class="profit-title-box flexWrap">
					<view>补扣团单系统服务费</view>
					{{day_platform_commission||'0.00'}}
				</view>
				<view class="profit-item flexWrap" v-for="(item,index) in day_platform_commission_list" :key="index">
					<view>{{item.report_date}}</view>
					<view>{{item.money}}</view>
				</view>
				<uni-load-more v-if="showLoadStatus" :status="status"  :content-text="contentText" />
				<view class="empty-box" v-if="showEmpty">
					<image src="https://static.mo-yu.vip/wechat/images/orderEmpty.png"></image>
				</view>
			</view>
		</template>
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				pageOpc:0,
				day_platform_commission_list:[
					{
						report_date:"2024-09-21",
						money:10
					}
				],
				day_platform_commission:0,
				//下拉刷新
				page: 1,
				size:20,
				showEmpty: true,
				showLoadStatus: false,
				more: true,
				contentText: {
					contentdown: '上拉加载更多~',
					contentrefresh: '加载中...',
					contentnomore: '已经到底了~~'
				},
				status: 'loading',
				starTime:"",
				endTime:"",
				type:"day"
			}
		},
		onLoad(ops) {
			this.starTime=ops.starTime
			this.endTime=ops.endTime
			this.type=uni.getStorageSync('type')
			this.freshList();
		},
		onReady(){
			setTimeout(() => {
				this.pageOpc=1
			}, 100)
		},
		// 触底刷新
		onReachBottom() {
			if (this.more) {
				this.getData()
			}
		},
		// 下拉刷新
		onPullDownRefresh: function() {
			this.freshList();
			this.$tools.loadIng()
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 500)
		},
		methods: {
			// 刷新列表
			freshList() {
				this.page = 1
				this.more = true
				this.status = 'loading'
				this.day_platform_commission_list = []
				this.getData();
			},
			getData(){
				let self=this
				this.$request.post(this.$api.deduction_record, {
					page:this.page++,
					show_page:this.size,
					store_id:uni.getStorageSync('store_id'),
					start_time:this.starTime,
					end_time:this.endTime,
					type:this.type
				}, {
					token:true
				}).then(res => {
					if (res.code == 1) {
						let {
							data = {}
						} = res;
						let newArray =data.data
						
						this.day_platform_commission=data.money
						for (let i in newArray) {
							newArray[i].createtime = this.$tools.formatDate(newArray[i].createtime)	
						}
						if (newArray.length == 0 && self.page == 2) {
							self.showEmpty = true
							self.showLoadStatus = false
							self.more = false // 不能再次请求了
							return false;
						} else {
							self.showLoadStatus = true
							self.more = true
							self.showEmpty = false
							self.status = 'loading'
						}
						if (newArray.length < this.size) { // 说明没有更多数据
							self.status = 'noMore'
							self.more = false
							self.showEmpty = false
						}
						self.day_platform_commission_list=self.day_platform_commission_list.concat(newArray);
					}
				}).finally(() => {
					setTimeout(()=>{
						this.$tools.hideLoading()
					}, 1000)
				})
			},
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 0 30upx;
	}
	.profit-title-box{
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 32rpx;
		color: #26BCFD;
		line-height: 38rpx;
		font-style: normal;
		text-transform: none;
		margin-bottom: 24upx;
		align-items: baseline;
		background: #1D1C5C;
		border-radius: 12rpx;
		padding: 28upx;
		position:sticky;
		top: 0;
		.profit-title-right{
			align-items: flex-end;
			.look{
				font-size: 24upx;
			}
		}
	}
	.profit-item{
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 26rpx;
		color: rgba(255,255,255,0.8);
		line-height: 50rpx;
	}
</style>
